package com.ccs.onlinemusic.tools;


import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class BCryptTest {
    public static void main(String[] args) {
        //模拟从前端获取密码
        String passwrod="123456";

        BCryptPasswordEncoder bCryptPasswordEncoder =new BCryptPasswordEncoder();
        //加密处理
        String newPassword= bCryptPasswordEncoder.encode(passwrod);
        System.out.println(newPassword);
        //验证
        boolean result=bCryptPasswordEncoder.matches(passwrod,newPassword);
        System.out.println("加密密码与正确密码对比" + result);

        boolean result2=bCryptPasswordEncoder.matches("987",newPassword);
        System.out.println("加密密码与错误密码对比" + result2);
    }
}
